package com.j4dream.property.dao;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.Date;

@Repository
@Mapper
public interface SQLCacheDao {

    @Insert("INSERT INTO sqlcache (id,_value) VALUES(#{key}, #{value})")
    void addCache(@Param("key") String key, @Param("value") String value);

    @Insert("INSERT INTO sqlcache (id,_value, expire) VALUES(#{key}, #{value}, #{expire})")
    void addCache(@Param("key") String key, @Param("value") String value, @Param("expire") Date expire);

    @Select("SELECT value FROM salcache WHERE id=#{key}")
    String getCache(@Param("key") String key);

    @Update("UPDATE salcache SET expire=#{expire} WHERE id=#{key}")
    void expireAt(@Param("key") String key, @Param("expire") Date expire);

    @Delete("DELETE FROM sqlcache WHERE id=#{key}")
    void delCache(@Param("key") String key);
}
